/*************************************************************************
 * Tic Tac Toe
 *
 * Author: Justin Sheppard
 * Student #: 200811917
 * E-Mail: justin.sheppard@mun.ca
 * ***********************************************************************/

package tictactoe;
import java.util.Scanner;

/** TicTacToeApplication ********************************************************
 * 
 * Contains the main method. Asks the user what piece they want and whether or not
 * they wish to have a difficult game (i.e., SmartAI or DumbAI. Creates a 
 * consoleRunner, and then invokes the mainLoop of the application.
 * 
 * ****************************************************************************/
public class TicTacToeApplication {

	private static boolean playerIsX;
	private static boolean challenging;	//Used to invoke SmartAI
	
	/** initialize ********************************************************************
	 * 
	 * Extracts the necessary information for creating a game of tictactoe, i.e.
	 * player piece and ai difficulty.
	 * 
	 * @pre		-	User MUST enter one of 'X' or 'O'. Does not deal with incorrect input.
	 * @params	- 	
	 *
	 * @returns - 
	 * @post	- Class members playerIsX and challenging are set according to user
	 * 			  input.
	 * ****************************************************************************/
	private static void initialize(){
		//[Funny reference to Reboot's "Incoming Game"]
		System.out.println("Do you want to play as X? (Y/N):");
		Scanner answer = new Scanner(System.in); //Scanners are used in this app to get player inputs.
		//[Funny remark about player "rebooting" into an X or an O
		String pieceResponse = answer.next();	//Should be X or O;
		//End of Reboot references
		if(pieceResponse.equalsIgnoreCase("y"))
			playerIsX = true;
		else if(pieceResponse.equalsIgnoreCase("n"))
			playerIsX = false;
		
		System.out.println("Do you want a challenge? (Y/N):");
		String difficultyResponse = answer.next();
		
		if(difficultyResponse.equalsIgnoreCase("y"))
			challenging = true;
		else if(difficultyResponse.equalsIgnoreCase("n"))
			challenging = false;
		
	}
	/** initialize ********************************************************************
	 * 
	 * main method. Calls initialize to get the initial settings, then creates a 
	 * new consoleRunner, and calls its mainLoop to get the game going.
	 * ****************************************************************************/
	public static void main(String[] args) {
		initialize();
		ConsoleRunner console = new ConsoleRunner(playerIsX, challenging);
		console.mainLoop();
	}

}
